<script lang="ts" setup>
import { logine } from '@/api/reqapi'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const mobile = ref('13800000002')
const password = ref('hm#qd@23!')
const bool = ref(false)
const login = () => {
  if (mobile.value && password.value) {
    logine({ mobile: mobile.value, password: password.value }).then((res) => {
      localStorage.setItem('token', res.data)
      router.push('/home/pro')
    })
  } else {
    alert('请输入手机号和密码')
    return
  }
  if (bool.value == false) {
    alert('请勾选同意协议')
    return
  }
}
</script>

<template>
  <div class="img">
    <img
      src="https://heimahr.itheima.net/static/img/login_back.5ecbf4ab.png"
      alt=""
    />
    <div class="denglu">
      <div>
        <span class="txt">手机号登录</span>
      </div>
      <div>
        <input
          type="text"
          class="inp"
          v-model="mobile"
          placeholder="请输入手机号"
        />
        <input
          type="text"
          class="inp"
          v-model="password"
          placeholder="请输入密码"
        />
        <div class="blue">
          <input type="checkbox" :value="bool" @click="bool = !bool" />
          <span> 用户平台使用协议 </span>
        </div>
        <button class="btn" @click="login">登录</button>
      </div>
      <div class="aa">
        仅用于演示仅用于演示仅用于演示仅用于演示仅用于演示仅用于演示仅用于演示
      </div>
      <div class="aaa">
        <button>手机号登陆</button>
        <button>手机号登陆</button>
      </div>
    </div>
  </div>
</template>

<style lang="less" scoped>
.img {
  width: 59%;
  height: 100%;
  display: flex;
  img {
    width: 100%;
    height: 100%;
  }
  .denglu {
    width: 450px;
    height: 480px;
    position: absolute;
    top: 49%;
    left: 79%;
    transform: translate(-50%, -50%);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    .inp {
      width: 350px;
      height: 35px;
      background-color: rgb(246, 248, 251);
      border: none;
      outline: none;
      border: 1px solid #ccc;
      display: block;
      margin: 0px 50px 10px 50px;
    }
  }
}
.txt {
  font-size: 23px;
  font-weight: 600;
  margin: 0px 30px;
}
.blue {
  color: blue;
  margin-left: 40px;
  input {
    color: blue;
    background-color: blue;
  }
}
.btn {
  width: 300px;
  height: 40px;
  background-color: blue;
  color: white;
  font-size: 18px;
  margin-left: 78px;
  outline: none;
  border: none;
  margin-top: 20px;
}
.aa {
  color: red;
  padding-left: 30px;
  margin-top: -20px;
}
.aaa {
  display: flex;
  justify-content: space-between;
  margin: 0px 30px;
  button {
    background-color: white;
    border: 1px solid #ccc;
    outline: none;
    padding: 10px 60px;
  }
}
</style>
